package book;

public class PrintString implements Runnable{

	private boolean continuePrint = true;

	public boolean isContinuePrint() {
		return continuePrint;
	}

	public void setContinuePrint(boolean continuePrint) {
		this.continuePrint = continuePrint;
	}
	
	public void printString(){
		
		while(continuePrint){
			
			System.out.println("run printString threadName:" + Thread.currentThread().getName());
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
	
	@Override
	public void run() {

		printString();
	}
	
	public static void main(String[] args) {
		
		PrintString print = new PrintString();
		Thread t = new Thread(print);
		t.start();
		
		System.out.println("我要停止它：" + Thread.currentThread().getName());
		print.setContinuePrint(false);
	}
}
